<template>
    <span>
      <el-menu mode="horizontal" class="el-menu--right">
        <el-menu-item index="/about">
          <nuxt-link to="/about">关于</nuxt-link>
        </el-menu-item>
        <el-menu-item @click="logout">
          <nuxt-link to="">退出</nuxt-link>
        </el-menu-item>
      </el-menu>
      <slot />
    </span>
  </template>

  <script setup>

  const logout = async () => {
    let { data, pending, error, refresh } = await useFetch('/api/logout')
    console.log('登出成功')
    //清除登录状态
    const {  reset } = await useSession()
    reset()
    const router = useRouter()
    router.push('/login')
  }
  </script>
